{% extends '::base.html.twig' %} 
{% block module_name %}Articulos{% endblock %}
{% block title %}Articulos :: Editar{% endblock %}

{% block body %}
<h2>Articulos :: Editar</h2>
<div class="widget_inside records_list">
    <div class="form">
        <form action="{{ path('articulos_update', { 'id': entity.id }) }}" method="post" {{ form_enctype(edit_form) }} id="formID">
            {{ form_widget(edit_form) }}
            <div class="clearfix">
                <label>Es Pieza</label>
                <div class="input">
                    <input type="checkbox" name="esPieza" id="esPieza" {% if entity.Kit != null %}checked{% endif %} />
                </div>
            </div>
            <div class="clearfix" id="contenedor">
                <label>Articulo Contenedor</label>
                <div class="input">
                    <select name="contenedor">
                        {% for item in entities %}
                            <option value="{{ item.id }}" {% if entity.Kit != null %}{% if item.id == entity.Kit.id %}selected{% endif %}{% endif %}>{{ item }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class="clearfix grey-highlight"> 
                <div class="input no-label">
                    <button type="submit" class="button blue">Guardar</button>
                </div>
            </div>
        </form>
        <script>
        $(document).ready(function(){
            $("#formID").validationEngine('attach');
            
            $("#contenedor").hide();
            
            function check(){
                if($("#esPieza").is(':checked')){
                    $("#contenedor").show().effect("highlight", {}, 900);
                }else{
                    $("#contenedor").hide();
                }
            }
            
            check();
            
            $("#esPieza").live("click", function(){
                check();
            });
           });
        </script>
    </div>
    <div class="margin_top_15 right">
                    <form action="{{ path('articulos_delete', { 'id': entity.id }) }}" method="post" style="display: inline-block;">
        {{ form_widget(delete_form) }}
        <button type="submit" class="button black">Eliminar</button>
    </form>
    <a href="{{ path('articulos') }}" class="button">Regresar a la Lista</a>
    </div>
</div>
{% endblock %}